package com.cs.pk.form.dialog;

import org.eclipse.swt.SWT;
import org.eclipse.swt.layout.GridData;
import org.eclipse.swt.layout.GridLayout;
import org.eclipse.swt.widgets.Button;
import org.eclipse.swt.widgets.Composite;

public class StatusControl {
	
	private String titleStr = null;
	private Button actions[] = null; 
	private Composite parent = null;
	public StatusControl(String titleStr) {
		this.titleStr = titleStr;
	}
	
	public void createControl(Composite parent) {
		Composite bottomControl = new Composite(parent ,SWT.NONE);
		GridData gridData = new GridData(GridData.FILL_HORIZONTAL);
		gridData.grabExcessHorizontalSpace = true;
		gridData.horizontalAlignment = SWT.END;
		gridData.heightHint =50;
		
		bottomControl.setLayoutData(gridData);
		//bottomControl.setLayout(new GridLayout(2,false));
		this.parent = bottomControl;
		//attachSaveButton("Save");
		//attachCancelButton("Cancel");
		

	}
	
	
//	public Button attachSaveButton(String text) {
//		save = new Button(parent,SWT.PUSH);
//		save.setText(text);
//		
//		return save;
//	}
//	
//	public Button attachCancelButton(String text) {
//		cancel = new Button(parent,SWT.PUSH);
//		cancel.setText(text);
//		return cancel;
//	}
	
	public Button[] createButtons(String[] name,int noOfButton){
	    actions = new Button[noOfButton];
	    parent.setLayout(new GridLayout(noOfButton,false));
	    for (int i = 0; i < actions.length; i++) {
		actions[i] = new Button(parent,SWT.PUSH);
		actions[i].setText(name[i]);
		actions[i].setLayoutData(new GridData(60,25));
	    }
	    return actions;
	}
	
	public void dispose() {
//		save.dispose();
//		cancel.dispose();
	    if(actions!=null){
	        for (int i = 0; i < actions.length; i++) {
		    actions[i].dispose();
		}
	        actions = null;
	    }
	    
		parent.dispose();
	}
	

}
